package com.wn.pettyloan.service.impl;

import com.wn.pettyloan.dto.UserDto;
import com.wn.pettyloan.entity.Userinfo;
import com.wn.pettyloan.mapper.UserinfoMapper;
import com.wn.pettyloan.service.UserinfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: pettyloan
 * @ClassName UserinfoServiceImpl
 * @description: 用户详情信息表
 * @author: meibing
 * @create: 2022-12-07 14:18
 * @Version 1.0
 **/
@Service("userinfoService")
public class UserinfoServiceImpl implements UserinfoService {

    @Resource
    private UserinfoMapper userinfoMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    /**
     * @Description 对用户详情表新增，同时更新用户表的id，进行绑定
     * @Param
     * @return
     * @Date 15:20 2022/12/7
     * @Author meibing
     **/
    @Override
    public int insertSelective(Userinfo record) {

        return userinfoMapper.insert(record);
    }

    @Override
    public Userinfo selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Userinfo record) {
        return userinfoMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public Userinfo selectByUser(UserDto userDto) {
        return userinfoMapper.selectByUse(userDto);
    }

    @Override
    public Userinfo selectByDebitId(Integer debitId) {
        List<Userinfo> userInfo =userinfoMapper.selectByDebitId(debitId);
        return userInfo.size()==1?userInfo.get(0):null;
    }
}